#pragma once
#include "InputSource.h"
#include "Pal/VideoIn.h"
namespace Media{
class HdmiInputSource:public InputSource, public std::enable_shared_from_this<HdmiInputSource>{
    public:
        using Ptr = std::shared_ptr<HdmiInputSource>;
        static Ptr Instance();

        HdmiInputSource();
        ~HdmiInputSource() override;
        FrameConsumerId AddVFrameConsumer(std::function<void (const AVFrame::Ptr)> framecb) override;
        bool RemoveVFrameConsumer(FrameConsumerId id) override;
        void ReleaseFrame(void *frame);
    protected:
        bool OpenSource() override;
        bool CloseSource() override;
    private:
        void frameProc(void *frame);
        VideoInput* m_videoIn;

        std::recursive_mutex m_mux;
        std::map<FrameConsumerId, std::function<void (const AVFrame::Ptr&)>> m_frameConsumers;
        uint32_t m_frameConsumerIndex;
    };
}